package Pojo;

import java.util.Scanner;

/**
 * 银行类
 * 
 * @author 吴春明
 * 
 */
public class Bank {
	public String name = "bdqn";// 姓名
	public String account = "88888888";// 账号
	public int password = 123456;// 密码
	public double deposit = 1000000;// 存款额

	/**
	 * 改密码
	 * 
	 * @param password原密码
	 * @param password1新密码
	 * @return
	 */
	public String getPassword(int password1, int password2, int password3) {
		if (this.password == password1 && password2 == password3) {
			this.password = password2;
			return "密码修改成功！" + "新密码为" + this.password;
		} else {
			return "原密码错误或二次新密码输入不一致！";
		}
	}

	/**
	 * 存款
	 * 
	 * @param money存的钱
	 * @return
	 */
	public void getDeposit(double money1) {
		if (money1 <= 0) {
			System.out.println("输入有误！");
			return;
		}
		System.out.println(deposit = deposit + money1);
	}

	/**
	 * 取款
	 * 
	 * @param money取得钱
	 * @return
	 */
	public void getWithdraw(double money2) {
		if (money2 <= 0 || money2 > deposit) {
			System.out.println("输入有误或余额不足！");
			return;
		}
		System.out.println(deposit = deposit - money2);
	}

	/**
	 * 利息
	 * 
	 * @param year年
	 * @return
	 */
	public double getInterest(int year) {
		return deposit * year * 0.01;
	}

	/**
	 * 管理系统
	 */
	public void show() {
		boolean m = true;
		System.out.println("\t银行管理系统");
		System.out.println("***************************");
		Scanner input = new Scanner(System.in);
		while (m) {
			System.out.println("请选择1.改密2.存款3.取款4.计算利息5.退出");
			String num = input.next();
			switch (num) {
			case "1":
				System.out.println("请输入原密码：");
				int password1 = input.nextInt();
				System.out.println("请输入新密码：");
				int password2 = input.nextInt();
				System.out.println("请再次输入新密码：");
				int password3 = input.nextInt();
				System.out
						.println(getPassword(password1, password2, password3));
				break;
			case "2":
				System.out.println("请输入存款金额:");
				double money2 = input.nextDouble();
				getWithdraw(money2);
				break;
			case "3":
				System.out.println("请输入取款金额:");
				double money1 = input.nextDouble();
				getDeposit(money1);
				break;
			case "4":
				System.out.println("请输入存款年限:");
				int year = input.nextInt();
				System.out.println(getInterest(year));
				break;
			case "5":
				m = false;
				break;
			default:
				System.out.println("输入错误，请重新输入");
			}
		}
		System.out.println("程序结束！");
	}
}
